package com.aliang.frame.domain.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 权限表
 */
public enum AuthEnum {

    //超级管理员权限
    SUPER_ADMIN(0, "SUPER"),

    // 用户管理权限
    USER_CONTROL(7, "USER-CONTROL"),

    //角色管理
    ROLE_CONTROL(8,"ROLE-CONTROL"),

    //部门管理
    DEPT_CONTROL(9, "DEPT-CONTROL"),
    ;
    int code;
    String name;

    AuthEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    private static final Map<Integer, AuthEnum> keyMap = new HashMap<>();

    static {
        for (AuthEnum item : AuthEnum.values()) {
            keyMap.put(item.getCode(), item);
        }
    }

    public static AuthEnum fromCode(Integer code) {
        return keyMap.get(code);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRoleName() {
        return "ROLE_" + name;
    }

}
